// pages/teamInfo/index.js
import {
  request
} from "../../request/request.js";
Page({

  /**
   * 页面的初始数据
   */
  data: {
    num:0,
    group_id:0,
    AdminList: [{
      id: 0,
      name: '郝鸿宇',
      class: '超级管理员',
      post: '创始人'
    }],
    MemberList: [{
        id: 0,
        name: '郝鸿宇',
        class: '超级管理员',
        post: '创始人'
      },
      {
        id: 1,
        name: 'hhh',
        class: '管理员',
        post: '队长'
      }
    ],
    list: [{
      name: "scale-up"
    }]
  },

  onLoad: function (options) {
    var that = this;
    let TeamName = wx.getStorageSync("AddTeamName");
    let LearderName = wx.getStorageSync("getLearderName");
    let LearderTelName = wx.getStorageSync("getLeaderTelrName");
    let Teamreamrk = wx.getStorageSync("Teamreamrk");
    that.setData({
      TeamName,
      LearderName,
      LearderTelName,
      Teamreamrk
    });
    var that = this;
        let baseUrl = 'http://172.17.60.141/';
        let StudentID = wx.getStorageSync("StudentID");
        request({
                url: baseUrl + 'group/Member',
                data: {
                  StudentID: StudentID,
                },
                method: 'GET',
            })
            .then(result => {
                console.log(result.data);
                for(let i=0;i<result.data.length;++i){
                  console.log(result.data[i]);
                  if(result.data[i].GroupID.GroupName == that.data.TeamName){
                    wx.setStorageSync('username', result.data[i].GroupName)
                    that.setData({
                      group_id:result.data[i].GroupID.GroupID
                    })
                  }
                }

            })
},
  BacktoTeam:function (e){
    var that = this;
    var anmiaton = e.currentTarget.dataset.class;
    that.setData({
      animation: anmiaton
    })
    setTimeout(function () {
      that.setData({
        animation: ''
      })
    }, 1000)
    
    wx.switchTab({
      url:'/pages/team/index'
    })
  }
})